package lambda;

import com.sun.xml.internal.ws.api.model.wsdl.WSDLOutput;

import java.util.function.BiFunction;

/**
 * @author yangwenqi
 * @decs TODO
 * @date 2025/5/6
 * BiFunction<T, U, R>练习
 * 将String类型的姓名、Integer类型的年龄，转换成Person对象
 */
public class BiFunctionDemo {
    public static void main(String[] args) {
        Person p=getPerson(new BiFunction<String, Integer, Person>() {
            @Override
            public Person apply(String name, Integer age) {
                return new Person(name,age);
            }
        },"张三",30);
        System.out.println(p);
    }
    public static Person getPerson(BiFunction<String, Integer, Person> biFunction
            , String name, int age) {
        return biFunction.apply(name, age);
    }
}
class Person{
    private String name;
    private int age;

    public Person() {
    }

    public Person(String name, int age) {
        this.name = name;
        this.age = age;
    }

    /**
     * 获取
     * @return name
     */
    public String getName() {
        return name;
    }

    /**
     * 设置
     * @param name
     */
    public void setName(String name) {
        this.name = name;
    }

    /**
     * 获取
     * @return age
     */
    public int getAge() {
        return age;
    }

    /**
     * 设置
     * @param age
     */
    public void setAge(int age) {
        this.age = age;
    }

    public String toString() {
        return "Person{name = " + name + ", age = " + age + "}";
    }

}
